<template>

	<van-pull-refresh v-model="isLoading" @refresh="onRefresh">
		<!-- 搜索框 -->
		<my-search></my-search>
		<!-- 轮播 -->
		<my-swiper :images2="images2"></my-swiper>
		<!-- 分类 -->
		<my-category :category2="category2"></my-category>
		<!-- 通知栏 -->
		<my-notice></my-notice>
		<!-- 推荐 -->
		<my-recommend :floors="floor1" :floorName="floorName.floor1"></my-recommend>
		<my-recommend :floors="floor2" :floorName="floorName.floor2"></my-recommend>
		<my-recommend :floors="floor3" :floorName="floorName.floor3"></my-recommend>
		<!-- 热卖商品 -->
		<my-hotgoods :hootgoods="hootgoods"></my-hotgoods>
		<!--  -->
	</van-pull-refresh>


</template>


<script>
	import { Toast } from 'vant';
	import {
		getIndexInfo
	} from '@/commonApi/request.js'
	import mySearch from './components/mySearch.vue'
	import mySwiper from './components/mySwiper.vue'
	import myCategory from './components/myCategory.vue'
	import myNotice from './components/myNotice.vue'
	import myRecommend from './components/myRecommend.vue'
	import myHotgoods from './components/myHotgoods.vue'
	export default {
		components: {
			mySearch,
			mySwiper,
			myCategory,
			myNotice,
			myRecommend,
			myHotgoods
		},
		data() {
			return {
				isLoading: false,
				images2: [],
				category2: [],
				floor1: [],
				floor2: [],
				floor3: [],
				floorName: "",
				hootgoods: []
			}
		},
		methods: {
			onRefresh(){
				setTimeout(()=>{
					this.getData();
					this.isLoading=false;
					Toast('刷新成功');
					
				},1000)
			},
			async getData() {
				var _self = this
				let {
					data
				} = await getIndexInfo()
				// console.log(data)
				var arr1 = data.data.slides
				var arr2 = data.data.category
				var flo3 = data.data.floor3
				var flo2 = data.data.floor2
				var flo1 = data.data.floor1
				var hotg = data.data.hotGoods
				for (let i = 0; i < arr1.length; i++) {
					arr1[i].image = (arr1[i].image).toString().replace(/oa/, "imgs")
				}
				for (let i = 0; i < arr2.length; i++) {
					arr2[i].image = (arr2[i].image).toString().replace(/oa/, "imgs")
				}
				for (let i = 0; i < flo3.length; i++) {
					flo3[i].image = (flo3[i].image).toString().replace(/oa/, "imgs")
				}
				for (let i = 0; i < flo2.length; i++) {
					flo2[i].image = (flo2[i].image).toString().replace(/oa/, "imgs")
				}
				for (let i = 0; i < flo1.length; i++) {
					flo1[i].image = (flo1[i].image).toString().replace(/oa/, "imgs")
				}
				for (let i = 0; i < hotg.length; i++) {
					hotg[i].image = (hotg[i].image).toString().replace(/oa/, "imgs")
				}
				_self.images2 = arr1
				_self.category2 = arr2
				_self.floor3 = flo3
				_self.floor2 = flo2
				_self.floor1 = flo1
				_self.hootgoods = hotg
				_self.floorName = data.data.floorName
				console.log(_self.category2)

			}
		},
		created() {
			this.getData()

		}
	}
</script>

<style>

</style>
